package com.wen.controller;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "AjaxDemoServlet", value = "/AjaxDemoServlet")
public class AjaxDemoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取客户端发送的表单数据
        String strUserName = request.getParameter("userName");
        String strUserAge = request.getParameter("userAge");
        System.out.println("userName:" + strUserName);
        System.out.println("userAge:" + strUserAge);
        // ajax在servlet中使用response的out输出流对象，将响应内容写到网络上即可
        PrintWriter out = response.getWriter();
        out.write("这里是ajax的服务器响应内容。。。。");
        // 清空发送器内容
        out.flush();
    }
}
